package com.un.ebs.inventory.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.un.ebs.inventory.domain.AccountMonth;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * (AccountMonth)表数据库访问层
 *
 * @author liubo
 * @since 2020-09-17 17:26:41
 */
public interface AccountMonthMapper extends BaseMapper<AccountMonth> {

    @Select("select * from tb_account_month where account_year=#{year} and account_month=#{month}")
    AccountMonth selectByYearMonth(@Param("year") int year, @Param("month") int month);

    @Select("exec sp_close_account #{year},#{month},#{userId},#{tenantId}")
    void close(@Param("year") int year, @Param("month") int month, @Param("userId") String userId, @Param("tenantId") String tenantId);

    @Select("exec sp_close_cancel_account #{year},#{month},#{tenantId}")
    void cancelClose(@Param("year") int year, @Param("month") int month, @Param("tenantId") String tenantId);

    @Select("exec sp_update_account #{year},#{month},#{tenantId}")
    void update(@Param("year") int year, @Param("month") int month, @Param("tenantId") String tenantId);

    @Update("update tb_account_month set sync_status=1,sync_time=getdate() where id = #{accountId}")
    void updateSyncComplete(@Param("accountId") String accountId);
}